#include<iostream>
#include<cstring>
using namespace std;
const int N = 10;
char mp[N][N];
bool st[N][N];
int col[N];
int row[N];
int n, k;
bool dfs(int x, int y, int sum)
{
	if (y == n) {
		x++;
		y = 0;
	}
	if (sum == k) {
		for (int i = 0; i < n; i++) {
			if (row[i] == 0 || row[i] == 1 || col[i] == 0 || col[i] == 1) {
				k--;
				return 1;
			}
		}
	}
	//ѡ
	if (mp[x][y] == '#') {
		sum++;
		col[y]++;
		row[x]++;
		if (dfs(x, y + 1, sum)) {
			return 1;
		}
		sum--;
		col[y]--;
		row[x]--;
	}
	dfs(x, y + 1, sum);
	return 0;
}
int main()
{
	while (cin >> n >> k) {
		if (n == -1 && k == -1) {
			break;
		}
		memset(mp, 0, sizeof(mp));
		memset(st, 0, sizeof(st));
		for (int i = 0; i < n; i++) {
			cin >> mp[i];
		}
		int ans = 0;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (mp[i][j] == '#'&&!st[i][j]) {
					if (dfs(i, j, 0)) {
						ans++;
					}
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}